<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input v-model="val" type="text">


    </div>

    <script src="./vue.js"></script>

    <script>
        new Vue ({
            el : "#app" ,
            data : {
                val : "",
                obj : {
                    name : "张三" ,
                    age : 18
                }
            },
            watch : {
                val( newValue , oldValue ) {
                    // newValue  当前的内容  
                    // oldValue  上一次的内容
                    // console.log(newValue, oldValue)
                    if (newValue.length === 11) {
                        alert("正确")
                    }
                },
                // 监听引用类型   需要开启深度监听
                obj : {
                    deep : true ,
                    handler(newValue) {
                        console.log(newValue);
                    }
                }
            }
        })
    </script>
</body>
</html>